<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import Reject from "./../reject/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {
      ShareQrcodeBox: async () =>
            Vue.extend(await Vue.prototype.$vFN.Components.Base.ShareQrcodeBox()),
  },
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "admin/goods/index",
        // delete: "admin/category/del",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {
        name: "",
        status: 0,
      },
      // 表格数据
      tableData: [],
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "标签名称",
            prop: "name",
            type: "",
          },
          {
            label: "绑定商品数",
            prop: "productCount",
            type: "",
          },
        ],
      },
      batchId: [],
    };
  },
  methods: {
      showCode(_id) {
            this.$refs["shareQrcodeBox" + _id].init({
                config: {
                    path: "/packGoodsDetail/store/index",
                    query: {
                        id: _id,
                    },
                },
            });
        },

    mydata() {
      console.log(this.mixinTable_tableData);
    },
    // 打开添加/修改
    editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
      });
    },
    // 详情
    details(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: [params_.id],
        data: params_.data,
        onSuccess: (res) => {
          this.mixinTable_refreshData();
        },
      });
    },
    // 审核通过
    pass(params_) {
      // console.log(this.mixinTable_selectTableData);
      console.log(this.batchId);
      if (params_.type == "batch") {
        if (this.mixinTable_selectTableData.length <= 0) {
          this.$vFN.Tools.messageError("请选择要审核的商品");
          return;
        }
        this.batchId = [];
        this.mixinTable_selectTableData.forEach((item) => {
          this.batchId.push(item.id);
        });
      } else if (params_.type == "single") {
        this.batchId = params_.id;
      }
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      })
        .then(async () => {
          let res = await this.$vFN.Http.post(
            {
              url: "admin/goods/pass",
              data: {
                ids: this.batchId,
              },
            },
            window
          );
          this.mixinTable_refreshData();
          if (res.success) {
            this.$vFN.Tools.messageSuccess("操作成功");
            this.editBoxClose();
            this.onSuccess();
          }
        })
        .catch(() => {});
    },
    // 驳回审核
    async reject(params_) {
      Reject.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
        data: params_.data,
        onSuccess: (res) => {
          this.mixinTable_refreshData();
        },
      });
    },
    // 初始化
    async init() {
      
      this.mixinTable_refreshData();
      this.mydata()
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>